package com.fauks.se.jdk8.lambda;

import javax.swing.*;

/**
 * lambda在图形化编程的广泛应用
 */
public class SwingTest {
    public static void main(String[] args) {
        JFrame frame = new JFrame("My JFrame");
        JButton jButton = new JButton("My Button");

        //之前java版本直接传入匿名类
        //ActionListener、ActionEvent、actionPerformed都是无意义的
        /*jButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                System.out.println("click");
            }
        });*/

        //使用lambda
        jButton.addActionListener(event-> System.out.println("click"));

        frame.add(jButton);
        frame.pack();
        frame.setVisible(true);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }
}
